package com.bwie.service;

import com.bwie.mapper.GoodsDao;
import com.bwie.pojo.VGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import org.springframework.stereotype.Service;
import util.IdWorker;


import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class GoodsService {

    @Autowired
    private GoodsDao goodsDao;
    @Autowired
    private IdWorker idWorker;
    //列表

    public List<VGoods> list(){
        return goodsDao.findAll();
    }

    public void add(VGoods goods) {
        goods.setId(idWorker.nextId()+"");
        goods.setStatus("0");
        goods.setPnum(1);
        goods.setSnum(1);




        goods.setFlag("1");

        goodsDao.save(goods);
    }

    public Page<Map<String, Object>> mohu(int page, int size, String name) {

        return goodsDao.mohu2("%"+name+"%", PageRequest.of(page-1,size));
    }
}
